import request from '@/utils/request'

export const userAPI = {
  // 获取当前用户信息
  getUserInfo: () => {
    return request({
      url: '/api/users/current/',
      method: 'get'
    })
  },

  // 上传头像
  uploadAvatar: (formData: FormData) => {
    return request({
      url: '/api/users/avatar/',
      method: 'post',
      data: formData,
      headers: {
        'Content-Type': 'multipart/form-data'
      }
    })
  },

  // 获取用户列表
  getUsers: (params?: any) => {
    return request({
      url: '/api/users/',
      method: 'get',
      params
    })
  },

  // 更新用户信息
  updateUserInfo: (id: number, data: any) => {
    return request({
      url: `/api/users/${id}/`,
      method: 'put',
      data
    })
  },

  // 修改密码
  changePassword: (data: any) => {
    return request({
      url: '/api/users/change-password/',
      method: 'post',
      data
    })
  }
}
